// 生成动态画作
function createArtworks() {
    const artworks = 100;
    const fragmentLeft = document.createDocumentFragment();
    const fragmentRight = document.createDocumentFragment();

    for(let i = 0; i < artworks; i++) {
        const img = document.createElement('div');
        img.className = 'artwork';
        img.style.background = `linear-gradient(45deg, 
            hsl(${Math.random()*360}, 70%, 40%),
            hsl(${Math.random()*360}, 70%, 30%))`;
        fragmentLeft.appendChild(img.cloneNode(true));
        fragmentRight.appendChild(img.cloneNode(true));
    }

    // 实现无缝滚动
    document.getElementById('left-gallery').append(fragmentLeft);
    document.getElementById('right-gallery').append(fragmentRight);
}

// 弹幕功能
function sendDanmaku() {
    const container = document.getElementById('danmaku-container');
    const input = document.getElementById('danmaku-input');
    
    const danmaku = document.createElement('div');
    danmaku.className = 'danmaku';
    danmaku.textContent = input.value;
    input.value = '';

    const yPos = Math.random() * 80;
    danmaku.style.top = yPos + '%';
    danmaku.style.left = '100%';
    
    container.appendChild(danmaku);
    
    // 动画效果
    requestAnimationFrame(() => {
        danmaku.style.transform = `translateX(-${container.offsetWidth + danmaku.offsetWidth}px)`;
        setTimeout(() => danmaku.remove(), 5000);
    });
}

// 初始化
window.onload = () => {
    createArtworks();
    
    // 添加画作悬浮效果
    document.querySelectorAll('.artwork').forEach(art => {
        art.onmouseenter = () => art.style.transform = 'scale(1.05)';
        art.onmouseleave = () => art.style.transform = 'scale(1)';
    });
};